<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *扫描记录
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
if($_RQ['op']=='list'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	
	if($_RQ['createtime']){
		$time_range=cfc('tools')->base64_decode($_RQ['createtime'],$_SESSION['base_key_str']);
		$time_range=json_decode($time_range,true);
		$return['params']['createtime']=$time_range;
		$params['createtime between']=array($time_range['tstart'],$time_range['tend']);
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 20;
	$total='';
	$fields=array('id','mid','card_number','createtime');
	$list=pdo_getslice('jy_move_agentcar_scan_log',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['number']=$this->card_number($item['card_number']);
			$item['nickname']=pdo_getcolumn('jy_move_agentcar_member',array('mid'=>$item['mid']),'name');
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'扫描记录'),
		),
		'list'=>array('data'=>'list','tip'=>"总扫描次数：{$total}",'list'=>array(
			array('name'=>'nickname','title'=>'会员','type'=>'string'),
			array('name'=>'number','title'=>'挪车卡号','type'=>'string'),
			array('name'=>'createtime','title'=>'扫描时间','type'=>'time'),
		)),
		'search'=>array(
			array('name'=>'createtime','title'=>'挪车时间','type'=>'time_range'),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='del'){
	$id=intval($_RQ['id']);
	if($id){
		pdo_delete('jy_move_agentcar_scan_log',array('id'=>$id));	
	}
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
		foreach($del as $id){
			$id=intval($id);
			if($id){
				pdo_delete('jy_move_agentcar_scan_log',array('id'=>$id));
			}
		}
	}
	exi('删除成功！');
}